home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
5_5.lha
/
5_5
/
5_5c2.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
829b
|
54 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ print out the tree in postfix format
tatic void postfixprint(tree* head)
if (head)
switch (head->type)
{
case PLUS: case DIV: case MUL:
postfixprint(head->left);
postfixprint(head->right);
cout << chr(head->type);
break;
case MINUS:
postfixprint(head->left);
if (head->right)
{
postfixprint(head->right);
cout << "-";
}
else
cout << "chg";
break;
case NUMBER:
cout << head->value;
break;
case LP:
postfixprint(head->left);
break;
case RP:
case END:
default:
error("invalid type within tree");
break;
}
else
error("NULL node found");
cout << " ";
oid expr:: print()
postfixprint(head);